import request from '@/utils/request'

export function listGoods(query) {
  return request({
    url: '/goods/list',
    method: 'get',
    params: query
  })
}

export function deleteGoods(data) {
  return request({
    url: '/goods/delete',
    method: 'post',
    data
  })
}

export function publishGoods(data) {
  return request({
    url: '/goods/create',
    method: 'post',
    data
  })
}

export function detailGoods(id) {

  return request({
    url: '/goods/detail',
    method: 'get',
    params: { id }
  })
  
}

export function detailGoods2(id) {
  return new Promise((resolve, reject) => {
    resolve(request({
      url: '/goods/detail',
      method: 'get',
      params: { id }
    }))
     
  })
}

export function editGoods(data) {
  return request({
    url: '/goods/update',
    method: 'post',
    data
  })
}

export function editGoodsSale(data) {
  return request({
    url: '/goods/updateSale',
    method: 'post',
    data
  })
}

export function listCatAndBrand() {
  return request({
    url: '/goods/catAndBrand',
    method: 'get'
  })
}

// 热销列表
export function hotlist(data) {
  return request({
    url: '/hotSellingGoods/queryList',
    method: 'get',
    params:data
  })
}

// 加购商品
export function additionalgoods(data) {
  return request({
    url: '/hotSellingGoods/queryAddGoodsList',
    method: 'get',
    params:data
  })
}

// 限定优惠
export function querylimitedofferList(data) {
  return request({
    url: '/hotSellingGoods/querylimitedofferList',
    method: 'get',
    params:data
  })
}

// 会员升级优惠
export function querymemberofferList(data) {
  return request({
    url: '/hotSellingGoods/querymemberofferList',
    method: 'get',
    params:data
  })
}

// 人气推荐
export function queryprecomList(data) {
  return request({
    url: '/hotSellingGoods/queryprecomList',
    method: 'get',
    params:data
  })
}

// 为你推荐
export function queryrecommendforyouList(data) {
  return request({
    url: '/hotSellingGoods/queryrecommendforyouList',
    method: 'get',
    params:data
  })
}


// 删除列表
export function hotdeleted(data) {
  return request({
    url: '/hotSellingGoods/deleted',
    method: 'get',
    params:data
  })
}
// 修改排序
export function updatehot(data) {
  return request({
    url: '/hotSellingGoods/setIsEnable',
    method: 'post',
    data
  })
}

// 添加商品列表
export function hotgoodslist(data) {
  return request({
    url: '/hotSellingGoods/goodslist',
    method: 'get',
    params:data
  })
}
// 添加商品
export function setIsEnableByList(data) {
  return request({
    url: '/hotSellingGoods/setIsEnableByList',
    method: 'post',
    data
  })
}

export function selectGoods() {
  return request({
    url: '/goods/selectGoods',
    method: 'get'
  })
}
export function updateGoodsItem(id,num) {
  return request({
    url: '/goods/updateGoodsItem',
    method: 'post',
    params: { id ,num}
  })
}
export function deleteGoodsItem(id) {
  return request({
    url: '/goods/deleteGoodsItem',
    method: 'post',
    params: { id }
  })
}

export function addGoodsItem(data) {
  return request({
    url: '/goods/addGoodsItem',
    method: 'post',
    data
  })
}
